/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.sgs.persist;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author MaUrO FiLhO
 */
@Entity
@Table(name = "material")
@NamedQueries({
    @NamedQuery(name = "Material.findAll", query = "SELECT m FROM Material m"),
    @NamedQuery(name = "Material.findByIdSeqmaterial", query = "SELECT m FROM Material m WHERE m.idSeqmaterial = :idSeqmaterial"),
    @NamedQuery(name = "Material.findByValidade", query = "SELECT m FROM Material m WHERE m.validade = :validade")})
public class Material implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_seqmaterial")
    private Integer idSeqmaterial;
    @Basic(optional = false)
    @Column(name = "validade")
    @Temporal(TemporalType.DATE)
    private Date validade;
    @JoinColumn(name = "id_suprimento", referencedColumnName = "id_suprimento")
    @ManyToOne(optional = false)
    private Suprimento suprimento;
    @JoinColumn(name = "id_seqmaterial", referencedColumnName = "id_seqmaterial", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Seqmaterial seqmaterial;
    @JoinColumn(name = "id_obra", referencedColumnName = "id_obra")
    @ManyToOne(optional = false)
    private Obra obra;
    @JoinColumn(name = "id_area", referencedColumnName = "id_area")
    @ManyToOne(optional = false)
    private Area area;

    public Material() {
    }

    public Material(Integer idSeqmaterial) {
        this.idSeqmaterial = idSeqmaterial;
    }

    public Material(Integer idSeqmaterial, Date validade) {
        this.idSeqmaterial = idSeqmaterial;
        this.validade = validade;
    }

    public Integer getIdSeqmaterial() {
        return idSeqmaterial;
    }

    public void setIdSeqmaterial(Integer idSeqmaterial) {
        this.idSeqmaterial = idSeqmaterial;
    }

    public Date getValidade() {
        return validade;
    }

    public void setValidade(Date validade) {
        this.validade = validade;
    }

    public Suprimento getSuprimento() {
        return suprimento;
    }

    public void setSuprimento(Suprimento suprimento) {
        this.suprimento = suprimento;
    }

    public Seqmaterial getSeqmaterial() {
        return seqmaterial;
    }

    public void setSeqmaterial(Seqmaterial seqmaterial) {
        this.seqmaterial = seqmaterial;
    }

    public Obra getObra() {
        return obra;
    }

    public void setObra(Obra obra) {
        this.obra = obra;
    }

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSeqmaterial != null ? idSeqmaterial.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Material)) {
            return false;
        }
        Material other = (Material) object;
        if ((this.idSeqmaterial == null && other.idSeqmaterial != null) || (this.idSeqmaterial != null && !this.idSeqmaterial.equals(other.idSeqmaterial))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.sgs.persist.Material[idSeqmaterial=" + idSeqmaterial + "]";
    }

}
